package nl.saxion.dbi.model;

import java.util.List;

import lombok.Data;
import nl.saxion.dbi.api.BazenbaseUtility;

@Data
public class Tabel implements StringBasedPropertyAble
{

	private int id;

	private String naam;

	private List<Veld> velden;

	private Key primaryKey;

	private List<Key> keys;

	private List<Row> data;

	public void addRow(Row row)
	{
		row.setTabel(this);
		getData().add(row);
	}

	@Override
	public Object getProperty(String property)
	{
		switch (property)
		{
		case "id":
			return id;
		case "naam":
			return naam;
		case "velden":
			return velden;
		case "primaryKey":
			return primaryKey;
		case "keys":
			return keys;
		case "data":
			return data;
		case "database_id":
			return BazenbaseUtility.getInstance().getDatabaseByTabel(this).getId();
		}
		throw new IllegalStateException("Property " + property + " is niet geldig voor Tabel");
	}
}